//


#import "NT_BaseController.h"

@interface NT_BaseController ()<UIGestureRecognizerDelegate>
{
    UINavigationItem    *_navItem;
    UINavigationBar     *_navBar;
}

@end

@implementation NT_BaseController

#pragma mark - Life Cycle

- (void)loadView
{
    [super loadView];
    
    [self.view setBackgroundColor:[UIColor whiteColor]];
    
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self.navigationController.navigationBar setBarTintColor:RGB(99, 184, 255)];
    // 去掉导航栏边界阴影线
    self.navigationController.navigationBar.shadowImage = [[UIImage alloc] init];
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self setupLeft];

}
- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
}
//设置基础字体颜色
- (UIStatusBarStyle)preferredStatusBarStyle
{
    return UIStatusBarStyleDefault;
}

- (void)nt_setupLeftAndRightwrurSetting:(id)obj block:(NavRightBlock)block
{
    _navRightBlock = block;
    if ([obj isKindOfClass:[NSString class]]) {
        UIButton *button = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 40, 30)];
        [button setTitle:obj forState:UIControlStateNormal];
        [button setTitleColor:RGBA(51, 51, 51, 1) forState:UIControlStateNormal];
        [button addTarget:self action:@selector(OnClick:) forControlEvents:UIControlEventTouchUpInside];
        [button.titleLabel setFont:FontPFRegular(kRelativeWidth(15))];
        UIBarButtonItem *rightItem = [[UIBarButtonItem alloc]initWithCustomView:button];
        self.navigationItem.rightBarButtonItem = rightItem;
    }else if ([obj isKindOfClass:[UIImage class]]){
        UIButton *button = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 25, 25)];
        [button setImage:obj forState:UIControlStateNormal];
        [button addTarget:self action:@selector(OnClick:) forControlEvents:UIControlEventTouchUpInside];
        UIBarButtonItem *rightItem = [[UIBarButtonItem alloc]initWithCustomView:button];
        self.navigationItem.rightBarButtonItem = rightItem;
    }
}

//*
- (void)setupLeft
{
    if (self.nt_isShowLeft) {
        
        UIButton *button = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 25, 25)];
        [button setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
        [button addTarget:self action:@selector(actionBack) forControlEvents:UIControlEventTouchUpInside];
        UIBarButtonItem *leftItem = [[UIBarButtonItem alloc]initWithCustomView:button];
        self.navigationItem.leftBarButtonItem = leftItem;
    }
}

- (BOOL)nt_isShowLeft
{
    return YES;
}


- (void)setnavBatTitle:(NSString *)title
{
    [self nt_isShowLeft];
    self.navigationItem.title = title;
    [self.navigationController.navigationBar setTitleTextAttributes:
     @{NSFontAttributeName:[UIFont systemFontOfSize:19],
       NSForegroundColorAttributeName:RGB(51, 51, 51)}];
}


//MARK:右键j点击
- (void)OnClick:(UIButton*)button {
    if (self.navRightBlock) {
        self.navRightBlock();
    }
}
- (void)actionBack
{
    [self.navigationController popViewControllerAnimated:YES];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
